﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Windows.Forms;
using NUnit.Framework;
using SpeechToText.STT;

namespace SpeechToText.TESTS
{
    [TestFixture]
    class MyTest
    {
        [Test]
        public static void test_WavResourse_Join()
        {
            WavResource A = new WavResource(WavHeader.CreateWaveFormat(44000), new byte[100]);
            WavResource B = new WavResource(WavHeader.CreateWaveFormat(44000), new byte[200]);
            WavResource C = new WavResource(WavHeader.CreateWaveFormat(88000), new byte[300]);

            WavResource D = A.Join(B);
            WavResource E = A.Join(C);
            WavResource F = C.Join(B);

            Assert.AreEqual(D.Data.Length, 300);
            Assert.IsNull(E);
            Assert.IsNull(F);
        }

        [Test]
        public static void test_WavResourse_isNoisy()
        {
            byte[] TestDate = new byte[10000];

            WavResource A = new WavResource(WavHeader.CreateWaveFormat(44000), TestDate);
            
            for (int i = 0; i < 10000; i ++)
            {
                TestDate[i] = 0;
            }

            for (int i = 0; i < 125; i += 4)
            {
                TestDate[i] = 200;
                TestDate[i + 1] = 200;
                TestDate[i + 2] = 100;
                TestDate[i + 3] = 100;
            }

            Assert.IsFalse(A.isNoisy(0.1, 0.5));
        }

        [Test]
        public static void test_FlacResouce()
        {
            byte[] B = new byte[10000];
            FlacResouce A = new FlacResouce(B, null);

            Assert.AreEqual(B, A.ToArray());

        }

        [Test]
        public static void test_Microphone(Control Owner)
        {
            Microphone Mic = new Microphone(Owner);

            WavResource Res = Mic.RecordFor(1000);

            DecodedSpeech DS = new DecodedSpeech(Res, Languages.Ru);

            Assert.IsEmpty(DS.Text);
            Assert.AreEqual(DS.TrueIndex, 1); 
        }

        [Test]
        public static void test_SystemStart()
        {
           
        }

    }
}
